import type { ThreadWorkerGlobalScope } from '@ohos.worker';
import { DialogMsgEntity } from '../../entity/WorkerMsgEntity';

//worker线程中处理Dialog相关消息
export class DialogWorkerMsgHandler {
    static workerPort;

    static init(workerPort: ThreadWorkerGlobalScope) : void {
        DialogWorkerMsgHandler.workerPort = workerPort;
    }

    static showDialog(message: string, title: string) : void {
        let dialogMsgEntity: DialogMsgEntity = new DialogMsgEntity('showDialog');
        dialogMsgEntity.title = title;
        dialogMsgEntity.message = message;
        DialogWorkerMsgHandler.workerPort.postMessage(dialogMsgEntity);
    }

    static showTextInputDialog(message: string) : void {
        let dialogMsgEntity: DialogMsgEntity = new DialogMsgEntity('showTextInputDialog');
        dialogMsgEntity.message = message;
        DialogWorkerMsgHandler.workerPort.postMessage(dialogMsgEntity);
    }

    static hideTextInputDialog() : void {
        let dialogMsgEntity: DialogMsgEntity = new DialogMsgEntity('hideTextInputDialog');
        DialogWorkerMsgHandler.workerPort.postMessage(dialogMsgEntity);
    }
}